.class public Lorg/microemu/app/classloader/ExtensionsClassLoader;
.super Ljava/net/URLClassLoader;
.source "ExtensionsClassLoader.java"


# static fields
.field private static final debug:Z


# instance fields
.field private acc:Ljava/security/AccessControlContext;


# direct methods
.method public constructor <init>([Ljava/net/URL;Ljava/lang/ClassLoader;)V
    .locals 1
    .parameter "urls"
    .parameter "parent"

    .prologue
    .line 57
    invoke-direct {p0, p1, p2}, Ljava/net/URLClassLoader;-><init>([Ljava/net/URL;Ljava/lang/ClassLoader;)V

    .line 58
    invoke-static {}, Ljava/security/AccessController;->getContext()Ljava/security/AccessControlContext;

    move-result-object v0

    iput-object v0, p0, Lorg/microemu/app/classloader/ExtensionsClassLoader;->acc:Ljava/security/AccessControlContext;

    .line 59
    return-void
.end method


# virtual methods
.method public addClasspath(Ljava/lang/String;)V
    .locals 5
    .parameter "classpath"

    .prologue
    .line 66
    new-instance v2, Ljava/util/StringTokenizer;

    const-string v3, ";"

    invoke-direct {v2, p1, v3}, Ljava/util/StringTokenizer;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 67
    .local v2, st:Ljava/util/StringTokenizer;
    :goto_0
    invoke-virtual {v2}, Ljava/util/StringTokenizer;->hasMoreTokens()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 69
    :try_start_0
    invoke-virtual {v2}, Ljava/util/StringTokenizer;->nextToken()Ljava/lang/String;

    move-result-object v1

    .line 70
    .local v1, path:Ljava/lang/String;
    const-string v3, "file:"

    invoke-virtual {v1, v3}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 71
    new-instance v3, Ljava/net/URL;

    invoke-direct {v3, v1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    invoke-virtual {p0, v3}, Lorg/microemu/app/classloader/ExtensionsClassLoader;->addURL(Ljava/net/URL;)V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 75
    .end local v1           #path:Ljava/lang/String;
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 76
    .local v0, e:Ljava/net/MalformedURLException;
    new-instance v3, Ljava/lang/Error;

    invoke-direct {v3, v0}, Ljava/lang/Error;-><init>(Ljava/lang/Throwable;)V

    throw v3

    .line 73
    .end local v0           #e:Ljava/net/MalformedURLException;
    .restart local v1       #path:Ljava/lang/String;
    :cond_0
    :try_start_1
    new-instance v3, Ljava/net/URL;

    new-instance v4, Ljava/io/File;

    invoke-direct {v4, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-static {v4}, Lorg/microemu/app/util/IOUtils;->getCanonicalFileURL(Ljava/io/File;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    invoke-virtual {p0, v3}, Lorg/microemu/app/classloader/ExtensionsClassLoader;->addURL(Ljava/net/URL;)V
    :try_end_1
    .catch Ljava/net/MalformedURLException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 79
    .end local v1           #path:Ljava/lang/String;
    :cond_1
    return-void
.end method

.method public addURL(Ljava/net/URL;)V
    .locals 0
    .parameter "url"

    .prologue
    .line 62
    invoke-super {p0, p1}, Ljava/net/URLClassLoader;->addURL(Ljava/net/URL;)V

    .line 63
    return-void
.end method

.method public getResource(Ljava/lang/String;)Ljava/net/URL;
    .locals 3
    .parameter "name"

    .prologue
    .line 111
    :try_start_0
    new-instance v1, Lorg/microemu/app/classloader/ExtensionsClassLoader$1;

    invoke-direct {v1, p0, p1}, Lorg/microemu/app/classloader/ExtensionsClassLoader$1;-><init>(Lorg/microemu/app/classloader/ExtensionsClassLoader;Ljava/lang/String;)V

    iget-object v2, p0, Lorg/microemu/app/classloader/ExtensionsClassLoader;->acc:Ljava/security/AccessControlContext;

    invoke-static {v1, v2}, Ljava/security/AccessController;->doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/URL;
    :try_end_0
    .catch Ljava/security/PrivilegedActionException; {:try_start_0 .. :try_end_0} :catch_0

    .line 116
    .local v0, url:Ljava/net/URL;
    if-eqz v0, :cond_0

    move-object v1, v0

    .line 124
    .end local v0           #url:Ljava/net/URL;
    :goto_0
    return-object v1

    .line 119
    :catch_0
    move-exception v1

    .line 124
    :cond_0
    invoke-super {p0, p1}, Ljava/net/URLClassLoader;->getResource(Ljava/lang/String;)Ljava/net/URL;

    move-result-object v1

    goto :goto_0
.end method
